<template>
  <div id="test4" style="height:100%">
    <el-card>
      <span>查询条件</span>
      <el-form label-width="100px" style="margin-top: 10px">
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="查询时间">
              <el-date-picker
                v-model="timePicker"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="班级">
              <el-input placeholder="请输入班级" style="width: 130px"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="学生姓名">
              <el-input v-model="queryData.name" placeholder="请输入学生姓名" style="width: 130px"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="学生学号">
              <el-input placeholder="请输入学生学号" style="width: 130px"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="4">
            <el-form-item label="学生卡号">
              <el-input placeholder="请输入学生卡号" style="width: 130px"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="设备名称">
              <el-input placeholder="请输入设备名称" style="width: 130px"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="通行方向">
              <el-input placeholder="请输入通行方向" style="width: 130px"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="进出类型">
              <el-input placeholder="请输入进出类型" style="width: 130px"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="设备号">
              <el-input placeholder="请输入设备号" style="width: 130px"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="3">
            <el-button @click="handleQuery" type="primary" style="width: 100px">查询</el-button>
          </el-col>
          <el-col :span="2">
            <el-button @click="handleDownload" type="primary" style="width: 100px">导出</el-button>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    <el-card style="margin-top: 20px; height:60%">
      <span>进出记录</span>
      <el-table
        ref="multipleTable"
        v-loading="loading"
        :data="pageInfo.list"
        max-height="360"
        tooltip-effect="dark"
        style="
          width: 100%;
          text-align: center;
          align-items: center;
          justify-content: center;
        "
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column prop="name" align="center" label="学生姓名" width="120px"></el-table-column>
        <el-table-column prop="photoUrl" align="center" label="抓拍照片" width="150px"></el-table-column>
        <el-table-column prop="number" align="center" label="学号" width="120px"></el-table-column>
        <el-table-column prop="clazz" align="center" label="班级" width="120px"></el-table-column>
        <el-table-column prop="device" align="center" label="设备名称" width="120px"></el-table-column>
        <el-table-column prop="deviceId" align="center" label="设备号" width="120px"></el-table-column>
        <el-table-column prop align="center" label="学生卡号" width="120px"></el-table-column>
        <el-table-column prop="fangxiang" align="center" label="通行方向" width="120px"></el-table-column>
        <el-table-column prop="jinchu" align="center" label="进出类型" width="120px"></el-table-column>
        <el-table-column prop="date" align="center" label="进出时间" width="200px" column-key="date"></el-table-column>
        <el-table-column align="center" fixed="right" label="操作" width="150px">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="handleCheck(scope.row)">查看</el-button>
            <el-button type="text" size="small" @click="handleDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="margin-top:10px">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageInfo.pageNum"
          :page-size="pageInfo.pageSize"
          layout="total, prev, pager, next, jumper"
          :total="pageInfo.total"
        ></el-pagination>
      </div>
    </el-card>
    <el-dialog title="学生详细信息" :visible.sync="dialogVisible" center width="40%">
      <el-row class="top_img" style="display: flex; justify-content: center">
        <img class="photo" src="../assets/images/shoyeimg1.jpg" height="200px" center />
      </el-row>
      <el-row style="margin-top: 10px">
        <el-col class="stu_info" :span="6" style="border-width: 2px 1px 1px 2px">
          <div class="grid-content bg-purple">姓名</div>
        </el-col>
        <el-col class="stu_info" :span="6" style="border-width: 2px 1px 1px 1px;">
          <div class="grid-content bg-purple">{{row.name}}</div>
        </el-col>
        <el-col class="stu_info" :span="6" style="border-width: 2px 1px 1px 1px">
          <div class="grid-content bg-purple">性别</div>
        </el-col>
        <el-col class="stu_info" :span="6" style="border-width: 2px 2px 1px 1px">
          <div class="grid-content bg-purple">123</div>
        </el-col>
      </el-row>
      <el-row>
        <el-col class="stu_info" :span="6" style="border-width: 1px 1px 1px 2px">
          <div class="grid-content bg-purple">学号</div>
        </el-col>
        <el-col class="stu_info" :span="6" style="border-width: 1px">
          <div class="grid-content bg-purple">{{row.number}}</div>
        </el-col>
        <el-col class="stu_info" :span="6" style="border-width: 1px">
          <div class="grid-content bg-purple">班级</div>
        </el-col>
        <el-col class="stu_info" :span="6" style="border-width: 1px 2px 1px 1px">
          <div class="grid-content bg-purple">{{row.clazz}}</div>
        </el-col>
      </el-row>
      <el-row>
        <el-col class="stu_info" :span="6" style="border-width: 1px 1px 1px 2px">
          <div class="grid-content bg-purple">设备名称</div>
        </el-col>
        <el-col class="stu_info" :span="6" style="border-width: 1px">
          <div class="grid-content bg-purple">{{row.device}}</div>
        </el-col>
        <el-col class="stu_info" :span="6" style="border-width: 1px">
          <div class="grid-content bg-purple">设备号</div>
        </el-col>
        <el-col class="stu_info" :span="6" style="border-width: 1px 2px 1px 1px">
          <div class="grid-content bg-purple">{{row.deviceId}}</div>
        </el-col>
      </el-row>
      <el-row>
        <el-col class="stu_info" :span="6" style="border-width: 1px 1px 1px 2px">
          <div class="grid-content bg-purple">卡号</div>
        </el-col>
        <el-col class="stu_info" :span="6" style="border-width: 1px">
          <div class="grid-content bg-purple">123</div>
        </el-col>
        <el-col class="stu_info" :span="6" style="border-width: 1px">
          <div class="grid-content bg-purple">通行方向</div>
        </el-col>
        <el-col class="stu_info" :span="6" style="border-width: 1px 2px 1px 1px">
          <div class="grid-content bg-purple">123</div>
        </el-col>
      </el-row>
      <el-row>
        <el-col class="stu_info" :span="6" style="border-width: 1px 1px 2px 2px">
          <div class="grid-content bg-purple">进出类型</div>
        </el-col>
        <el-col class="stu_info" :span="6" style="border-width: 1px 1px 2px 1px">
          <div class="grid-content bg-purple">123</div>
        </el-col>
        <el-col class="stu_info" :span="6" style="border-width: 1px 1px 2px 1px">
          <div class="grid-content bg-purple">进出时间</div>
        </el-col>
        <el-col class="stu_info" :span="6" style="border-width: 1px 2px 2px 1px;">
          <div class="grid-content bg-purple">{{row.date}}</div>
        </el-col>
      </el-row>
    </el-dialog>
  </div>
</template>
<script>
import {
  listAccess,
  downloadAccess
} from "@/api/jilu";//downloadAccess,
export default {
  name: "JingChu",
  //组件创建
  created() {},
  mounted() {
    this.getList()
  },
  data() {
    return {
      currentPage1: 4,
      row: "",
      dialogVisible: false,
      //时间选择
      timePicker: [],
      // 遮罩层
      loading: false,
      //查询参数
      queryData: {
        name: undefined,
        startTime: undefined,
        endTime: undefined,
        pageSize: 5,
        pageNum: 1,
      },
      pageInfo: {},
      multipleSelection: [],
      value1: "",
    };
  },
  methods: {
    /** 查询记录列表 */
    getList() {
      this.loading = true;
      listAccess(this.queryData).then((response) => {
        this.pageInfo = response.data.pageInfo;
        this.loading = false;
      });
    },
    /**查看详细信息操作 */
    handleCheck(row) {
      this.dialogVisible = true;
      this.row = row;
    },
    /**删除操作 */
    handleDelete(row) {
      console.log(row);
      this.$message("哈！不能删！");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryData.startTime = this.timePicker[0];
      this.queryData.endTime = this.timePicker[1];
      console.log(this.queryData);
      

      //this.getList();
      //this.$message.success("查询成功");
    },
    /**导出文件 */
    handleDownload() {
      downloadAccess();
    },
    /**分页 */
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    toggleSelection(rows) {
      if (rows) {
        rows.forEach((row) => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
  },
};
</script>
<style lang="less" scoped>
.stu_info {
  height: 60px;
  //line-height: 60px; //行高居中
  border: solid;
  display: table;
  margin: 0 auto;
}
.grid-content {
  font-size: 17px;
  display: table-cell;
  vertical-align: middle;
  padding: 0 10px 0 10px;
}
</style>
